Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] A little pointcut help please

within(<ClassLoaderHierarchy>) would be nice, but that would require
OSGi (I think) and wouldn't solve my current problem.

My question stands.  Anyone?

On Thu, Oct 8, 2009 at 11:52 PM, Gopinathan Balaji
<gopinathanbalaji@xxxxxxxxx> wrote:
>
> I think the difference is that package-protected classes are visible only to
> members of the same package. They're not visible to members of a different
> package of the same assembly (assembly is the term the OP used; I think JAR
> would be the appropriate analogy here).
>
> In any case, I think the OSGi bundles' manifest specification has solved
> this for Java components/applications. Only what is exposed through the
> bundle's manifest is visible/usable outside the bundle. In other words, all
> un-exposed classes are "protected internal".
>
> With AspectJ, I think we need some classloader magic to effect this (same as
> what OSGi does??), or, AspectJ supports something like a
> "within(<ClassLoaderHierarchy>)" expression.
>
> Thanks,
> Balaji
>
> ________________________________
> From: Wim Deblauwe <wim.deblauwe@xxxxxxxxx>
> To: aspectj-users@xxxxxxxxxxx
> Sent: Fri, October 9, 2009 12:00:58 PM
> Subject: Re: [aspectj-users] A little pointcut help please
>
> What is the difference between what you want to do here and "package
> protected" that is standard in java (e.g. not using private, protected or
> public modifiers) ?
>
> regards,
>
> Wim
>
> 2009/10/8 Matthew Adams <matthew@xxxxxxxxxxxxxxx>
>>
>> Hi all,
>>
>> Java has fused the concept of "namespace" and "component" in its
>> concept of "package".  This results in having to mark public things
>> that you really don't want public consumers to access.  .NET actually
>> fixes this with its "protected internal" scope:  only code from within
>> the current assembly can access the member scoped as protected
>> internal.
>>
>> Now, I have a declare error statement attempting to achieve
>> functionality similar to C#'s "protected internal" scope, whereby only
>> code from within the current package is allowed to access the thing
>> that is annotated with @ProtectedInternal.
>>
>> Here is my annotation & my declare error statement, but I'd like to
>> make it more general, replacing "org.foo.model.*" with something more
>> general that implies that access is disallowed from code that is
>> outside the called/accessed element's package, that is, not in the
>> annotated element's package.
>>
>> @Target( { ElementType.TYPE, ElementType.METHOD, ElementType.FIELD,
>>                ElementType.CONSTRUCTOR })
>> @Retention(RetentionPolicy.RUNTIME)
>> public @interface ProtectedInternal {}
>> ===============
>> public aspect ProtectedInternalDeclareError {
>>        declare error :
>>                (!within(org.foo.model.*)) // TODO:  replace this
>> hardcoding with
>> something more general
>>                        && (set(@ProtectedInternal * *)
>>                                || get(@ProtectedInternal * *)
>>                                || call(@ProtectedInternal * *(..))
>>                                || call(* (@ProtectedInternal *..*).*(..))
>>                                || call(@ProtectedInternal *.new(..))
>>                                || call((@ProtectedInternal *).new(..))
>>                )
>>                : "The target constructor, method, or field is not designed
>> for
>> public consumption; access is disallowed.";
>> }
>>
>> Help, anyone?
>>
>> Thanks,
>> Matthew
>> _______________________________________________
>> aspectj-users mailing list
>> aspectj-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>



-- 
mailto:matthew@xxxxxxxxxxxxxxx
skype:matthewadams12
yahoo:matthewadams
aol:matthewadams12
google-talk:matthewadams12@xxxxxxxxx
msn:matthew@xxxxxxxxxxxxxxx
http://matthewadams.me
http://www.linkedin.com/in/matthewadams


Back to the top