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

If you use interfaces within a package, the methods on the interfaces
must be public, even if those interfaces will only be used within the
package (as in our design).  When classes within the package implement
those interfaces, their methods are necessarily public.

That means that any code can call it.  That's why I'd like the
equivalent of .NET's "protected internal".

On Thu, Oct 8, 2009 at 11:30 PM, Wim Deblauwe <wim.deblauwe@xxxxxxxxx> wrote:
> 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